<?php
/**
 * 认证
 * 
 * @package SFramework
 * @author Shuky
 * @since v1.0
 * @version $Id: Auth.php 82 2010-12-23 18:23:35Z shukyoo@gmail.com $
 */
namespace SFramework;

class Auth
{
    protected static $_space = 'auth';

	public static function setSpace($space)
	{
		self::$_space = $space;
	}
    
	
	/**
	 * 是否有效
	 */
	public static function isValid()
	{
		return isset($_SESSION[self::$_space]);
	}
	
	
	/**
	 * 获取认证的数据
	 */
	public static function getAuth($key = null)
	{
		return empty($_SESSION[self::$_space]) ? '' : 
									(($key == null) ? $_SESSION[self::$_space] : $_SESSION[self::$_space][$key]);
	}
	
	
	/**
	 * 写入认证
	 */
	public static function setAuth($key, $value)
	{
		$_SESSION[self::$_space][$key] = $value;
	}
	
	
	/**
	 * 清除
	 */
	public static function clearAuth()
	{
		unset($_SESSION[self::$_space]);
	}
}